<?php

function smarty_function_get_all_carproperty_by_id($params, &$smarty) {
    //Get value from page
    $category_id    = $params['category_id'];
    $subcategory_id = $params['subcategory_id'];
    $brand_id       = $params['brand_id'];
    $model_id       = $params['model_id'];


    $pntables = pnDBGetTables();
    $tableCarProperty  = $pntables['innoforum_carproperty'];
    $columnCarProperty = $pntables['innoforum_carproperty_column'];

    $tableSubcategoryCarProperty  = $pntables['innoforum_subcategory_carproperty'];
    $columnSubcategoryCarProperty = $pntables['innoforum_subcategory_carproperty_column'];

      //Query data
      $sql = "SELECT
                $columnCarProperty[id],
                $columnCarProperty[name]  
              FROM
                $tableCarProperty ,
                $tableSubcategoryCarProperty
              WHERE
                $columnSubcategoryCarProperty[category_id] = $category_id
              AND
                $columnSubcategoryCarProperty[subcategory_id] = $subcategory_id
              AND
                $columnSubcategoryCarProperty[carproperty_id] = $columnCarProperty[id]
              ORDER BY
                $columnCarProperty[name] ASC 
            ";

      $column = array("id","name");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      $smarty->assign('carPropertyArray', $objectArray); 

}